﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Lisphi.Lab.PostSharpGettingStart
{
    class Program
    {
        static void Main(string[] args)
        {
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));

            SayHello();
            SayGoodBye();

            //Foobar foobar = new Foobar();
            //foobar.Foo();

            Console.Write("Press <enter> to exit.");
            Console.ReadLine();
        }

        [Trace("MyCategory")]
        private static void SayHello() 
        {
            string currentMethod = new StackTrace().GetFrame(0).GetMethod().ToString();
            Console.WriteLine("Hello, world. @{0}", currentMethod); 
        }

        [Trace("MyCategory")]
        private static void SayGoodBye() 
        {
            string currentMethod = new StackTrace().GetFrame(0).GetMethod().ToString();
            Console.WriteLine("Good bye, world. @{0}", currentMethod); 
        }
    }

    class Foobar
    {
        [Trace("MyCategory")]
        private void Bar()
        {
            Console.WriteLine("<Bar>");
        }

        [Trace("MyCategory")]
        public void Foo()
        {
            Console.WriteLine("<Foo> Bar start");
            this.Bar();
            Console.WriteLine("<Foo> Bar end");
        }
    }
}
